﻿//-----------------------------------------------------------------
//
// @(#)$Id: EbaySellingDetail.aspx.cs,v 1.0 2013/12/13 17:55:10 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 17:55:10 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using ebay.Dal.CenterDB_EbayTableAdapters;

public partial class UI_Orders_EbaySellingDetail : System.Web.UI.Page
{
    static string act = "";
    protected void Page_Load(object sender, EventArgs e)
    {
         if (!IsPostBack)
         {
             act = Request.QueryString["act"];
             if (!string.IsNullOrEmpty(act))
             {
                 switch (act)
                 {
                     case "view":
                         string orderId = Request.QueryString["id2"];
                         string ebayUserId = Request.QueryString["id"];
                         tid1.Value = ebayUserId;
                         tid2.Value = orderId;

                         T_EbaySellingTableAdapter adapter = new T_EbaySellingTableAdapter();
                         DataTable table = adapter.GetDataById(ebayUserId, orderId);
                         if (table.Rows.Count > 0)
                         {
                             DataRow r = table.Rows[0];
                             foreach (Control txtControl in this.form2.Controls)
                             {
                                 if (txtControl is HtmlInputText)
                                 {
                                     HtmlInputText txtBox = (HtmlInputText)txtControl;
                                     string colName = txtBox.ID.Substring(3, txtBox.ID.Length - 3);
                                     string val = r[colName].ToString();
                                     if (table.Columns[colName].DataType.Name == "DateTime")
                                     {
                                         DateTime valDate = DateTime.Parse(val);
                                         DateTime defaultDateTime = new DateTime(1900, 1, 1);
                                         if (valDate == defaultDateTime)
                                         {
                                             val = "";
                                         }
                                     }
                                     txtBox.Value = val;
                                 }
                                 else if (txtControl is HtmlSelect)
                                 {
                                     HtmlSelect ddList = (HtmlSelect)txtControl;
                                     string colName = ddList.ID.Substring(3, ddList.ID.Length - 3);
                                     ddList.Value = r[colName].ToString();

                                 }
                             }
                         }
                         break;
                 }
             }
         }
    }
}
